<!DOCTYPE html>
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
      <link rel="StyleSheet" type="text/css" href="/tpa/admin.css" />
      <link rel="StyleSheet" type="text/css" href="/tpa/jquery.Jcrop.css" />
      <link rel="StyleSheet" type="text/css" href="/tpa/jquery-ui.css" />
      <link rel="stylesheet" type="text/css" href="/lib/el/css/elrte.css" media="screen">
      <link rel="stylesheet" type="text/css" href="/lib/el/css/elfinder.css" media="screen">
      
      <script type="text/javascript" src="/lib/js/jquery.js"></script>
      <script type="text/javascript" src="/lib/js/jquery.ui.js"></script>
      <script type="text/javascript" src="/lib/js/jquery.Jcrop.js"></script>
      <script type="text/javascript" src="/lib/js/jquery.maskedinput.js"></script>
      <script type="text/javascript" src="/lib/js/swfobject.js"></script>
      <script type="text/javascript" src="/lib/js/jquery.uploadify.js"></script>
      <script type="text/javascript" src="/lib/el/elrte.js"></script>
      <script type="text/javascript" src="/lib/el/elfinder.js"></script>
      <script type="text/javascript" src="/lib/el/toolbars.js"></script>
      <script type="text/javascript" src="/lib/el/i18n/elrte.{%$lang.iso%}.js"></script>
      <script type="text/javascript" src="/lib/js/meccano.js"></script>
      <script type="text/javascript" src="/admin/thumbnailing.php"></script>
      
      {%ErrorHandler->getSuccess assign='make'%}
      
      <script type="text/javascript">
         {%strip%}{%foreach from=$langs item='l' name='i'%}
         {%if $smarty.foreach.i.first%}
         var langs = [
            {%/if%}
            {'id':'{%$l.id%}','alias':'{%$l.alias%}','title':'{%$l.title%}'}
            {%if !$smarty.foreach.i.last%},{%/if%}
            {%if $smarty.foreach.i.last%}
         ];
         {%/if%}
         {%/foreach%}{%/strip%}

         var default_lang = {%$default_lang%};
         var current_lang = {%$default_lang%};
         var editors = {};
         
         $(document).ready(function(){
            $('#tabedContent').tabs();
            {%if count($langs) > 1%}$('#lang_tabs').tabs();{%/if%}
            {%if $make%}{%$make.exec%}({%$make.result%});{%/if%}
            $('.wyswyg').each(function(){
              field_id = $(this).attr('id');
               var opts = {
                  lang: '{%$lang.iso%}',
                  fmOpen: function(callback) {
                     $('<div id="myelfinder" />').elfinder({
                        url : '/lib/el/connectors/php/connector.php',
                        lang : '{%$lang.iso%}',
                        dialog : { width : 900, modal : true, title : 'Files' },
                        closeOnEditorCallback : true,
                        editorCallback : callback
                     });
                  },
                  styleWithCSS : false,
                  height       : $(this).height(),
                  toolbar      : $(this).data('emode'),
                  cssfiles: ["/usr/css/elrt.css"]
               };
               editors[field_id] = new elRTE(this, opts);
               editors[field_id].val(document.getElementById('f_'+field_id+'_'+default_lang).value);
            });
         });
      </script>
   </head>
   <body>

      <form action="/admin/article{%if $DataObject->id != NULL%}/{%$DataObject->id%}{%else%}/{%$DataObject->cat%}/new{%/if%}.html" name="FORM_article" method="POST" enctype="multipart/form-data">
         <div style="padding: 5px 0 0 30px; height: 15px; overflow: hidden;"><span style="color:#777;">{%$TR->meccano->article%}</span>: <b> {%$DataObject->title%}</b></div>
         <div id="tabedContent">

            <input type="hidden" name="commit" value="1" />

            <ul class="fields_tabs">
            {%foreach from=$DataObject->getFields() key='tab_id' item='field_set'%}
            
               {%if $field_set->active eq 1%}
               <li><a href="#t_fields_{%$tab_id%}"><span>{%$field_set->title%}</span></a></li>
               {%/if%}
            {%/foreach%}

               {%if $CONFIG->comments('enabled') && ($authorizedUser->hasRole('MODER_COMMENTS') || $authorizedUser->hasRole('ADMIN'))%}
               <li><a href="#t_comments"><span>{%$TR->meccano->comments%} [{%$DataObject->countComments%}]</span></li>
               {%/if%}
            </ul>

            {%foreach from=$DataObject->getFields() key='tab_id' item='field_set'%}
            {%if $field_set->active eq 1%}
            <div id="t_fields_{%$tab_id%}">

               <!-- TAB: {%$field_set->title%} -->

               {%if $field_set->fieldset && $field_set->active%}

               {%$field_set->getFieldHTML($DataObject)%}
               
               {%else%}

               <table width="100%" border="0">
                  <col width="150">
                     <tbody>

                        {%foreach from=$field_set->fields item=field%}
                        {%if $field->active eq 1%}

                        <tr>
                           <td class="rt">
                              <label for="f_{%$field->alias%}" title="{%$field->alias%}">{%$field->title%}:</label> 
                           </td>
                           <td>
                              {%$field->getFieldHTML($DataObject)%}
                           </td>
                        </tr>

                        {%/if%}
                        {%/foreach%}
                     </tbody>
               </table>

               {%/if%}

               <!-- EOF TAB: {%$field_set->title%} -->

            </div>
            {%/if%}
            {%/foreach%}

            {%if $CONFIG->comments('enabled') && ($authorizedUser->hasRole('MODER_COMMENTS') || $authorizedUser->hasRole('ADMIN'))%}
            <div id="t_comments">
               {%assign var='comments' value=$DataObject->comments('all')%}
               {%include file='servlet.comments.html' cm=$comments%}
            </div>
            {%/if%}
         </div>

         <div style="margin:10px 0 0 15px;">
            <input type="button" value=" {%$TR->meccano->save%} " onclick="CommitForm('FORM_article');" />
         </div>

      </form>

      {%if count($langs) > 1%}
      <div id="lang_tabs">
      {%foreach from=$langs item='l' name='i'%}
      {%if $smarty.foreach.i.first%}<ul>{%/if%}
         <li><a href="#l_{%$l.id%}" onclick="SwitchLang({%$l.id%});"><span>{%$l.title%}</span></a></li>
         {%if $smarty.foreach.i.last%}</ul>
         {%/if%}
      {%/foreach%}
      {%foreach from=$langs item='l' name='i'%}
      <div id="l_{%$l.id%}"></div>
      {%/foreach%}
      </div>
      {%/if%}

   </body>
</html>